﻿<?php
include_once("./function.php");

//2数据处理
extract($_GET);//$id $pname $lev $show $cid
$id=trim($id);
$pname=trim($pname);
$lev=trim($lev);
$show=trim($show);
$cid=trim($cid);
//3判断修改分类名是否为空
if(empty($pname))
{
	msg("分类名修改不能为空","news_conf.php");exit;
}
//4判断修改的分类名是否重复
$sql="select * from ts_news_cate where cname='$pname'";
$res=mysqli_query($link,$sql);
if(is_object($res))
{
	if(mysqli_num_rows($res)>0)
	{
		msg("修改的分类名不能重复","news_conf.php");exit;
	}

}

//5修改分类
if(isset($_GET['cid']))
{
	$sql="update ts_news_cate set cname='$pname' where cid=$cid";
	if(mysqli_query($link,$sql))
	{
		if(mysqli_affected_rows($link)>0)
		{
			msg("修改成功","news_conf.php");exit;
		}
		else
		{
			msg("修改失败","news_conf.php");exit;
		}
	}
}
?>